//
//  FooterView.swift
//  SinaBlog
//
//  Created by 有何不可 on 16/1/6.
//  Copyright © 2016年 有何不可. All rights reserved.
//

import UIKit

class FooterView: UIView {
    
    var footerViewModel: PersonalBlogViewModel? {
        
        didSet {
            
            commentBtn.setTitle(footerViewModel?.comments_count_str, forState: .Normal)
            retweetBtn.setTitle(footerViewModel?.reposts_count_str, forState: .Normal)
            likeBtn.setTitle(footerViewModel?.attitudes_count_str, forState: .Normal)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
         backgroundColor = UIColor.whiteColor()
        setUI()
    }
    
    private func setUI() {
        
        let line1 = line()
        let line2 = line()
        addSubview(commentBtn)
        addSubview(retweetBtn)
        addSubview(likeBtn)
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.height.equalTo(retweetBtn.snp_height)
            make.width.equalTo(retweetBtn.snp_width)
        }
        
        retweetBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            
            make.right.equalTo(likeBtn.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            
            make.right.equalTo(self.snp_right)
            make.top.equalTo(self.snp_top)
            make.height.equalTo(retweetBtn.snp_height)
            make.width.equalTo(retweetBtn.snp_width)
        }
        
        addSubview(line1)
        addSubview(line2)
        
        line1.snp_makeConstraints { (make) -> Void in
            
            make.centerY.equalTo(self.snp_centerY)
            make.left.equalTo(commentBtn.snp_right)
        }
        
        line2.snp_makeConstraints { (make) -> Void in
            
            make.centerY.equalTo(self.snp_centerY)
            make.left.equalTo(retweetBtn.snp_right)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
     lazy var commentBtn: UIButton = {
        let btn = UIButton(type: .Custom)
        
        btn.setImage(UIImage(named: "timeline_icon_comment"), forState: .Normal)
        btn.setTitle("评论", forState: .Normal)
        btn.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(14)
        return btn
        }()
    
     lazy var retweetBtn: UIButton = {
        let btn = UIButton(type: .Custom)
        
        btn.setImage(UIImage(named: "timeline_icon_retweet"), forState: .Normal)
        btn.setTitle("转发", forState: .Normal)
        btn.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(14)
        return btn
        }()
    
     lazy var likeBtn: UIButton = {
        let btn = UIButton(type: .Custom)
        
        btn.setImage(UIImage(named: "timeline_icon_like"), forState: .Normal)
        btn.setTitle("点赞", forState: .Normal)
        btn.setTitleColor(UIColor.lightGrayColor(), forState: .Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(14)
        return btn
        }()
    
    private func line() ->UIImageView {
        
        return UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
        
    }
}